package com.huike.web.controller.acitivity;




import com.huike.activity.domain.TbActivity;
import com.huike.activity.service.TbActivityService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 活动管理Controller
 */
@RestController
@RequestMapping("/clues/activity")
public class TbActivityController extends BaseController {

    @Autowired
    private TbActivityService tbActivityService;

    /**
     * 查询活动管理列表  分页查询
     */
    @GetMapping("/list")
    public TableDataInfo list(TbActivity tbActivity) {
        startPage();
        List<TbActivity> list = tbActivityService.selectTbActivityList(tbActivity);
        return getDataTable(list);
    }

    @GetMapping("/listselect/{channel}")
    public AjaxResult selectTbActivityByChannel(@PathVariable String channel) {
        List<TbActivity> tbActivity = tbActivityService.selectTbActivityByChannel(channel);
        return AjaxResult.success(tbActivity);
    }


    /**
     * 获取活动管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tbActivityService.selectTbActivityById(id));
    }

    /**
     * 新增活动管理
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbActivity tbActivity) {
        return toAjax(tbActivityService.insertTbActivity(tbActivity));
    }


    /**
     * 修改活动管理
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TbActivity tbActivity) {
        return toAjax(tbActivityService.updateTbActivity(tbActivity));
    }

    /**
     * 删除活动管理
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tbActivityService.deleteTbActivityByIds(ids));
    }
}
